package com.forum.module.system.dal.dataobject.user;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.forum.framework.mybatis.core.dataobject.BaseDO;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 管理后台的用户 DO
 *
 * @author zihan.ouyang
 */
@TableName(value = "system_user", autoResultMap = true)
public class UserDO extends BaseDO {
    /**
     * 用户编号
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 用户账号
     */
    private String username;
    /**
     * 加密后的密码
     * <p>
     * 因为目前使用 {@link com.forum.framework.security.core.util.SecurityUtils#encryptPassword(String)} BCryptPasswordEncoder 加密器，所以无需自己处理加盐
     */
    private String password;
    /**
     * 用户昵称
     */
    private String nickname;
    /**
     * 备注
     */
    private String remark;
    /**
     * 用户邮箱
     */
    private String email;
    private String avatar;
    /**
     * 手机号码
     */
    private String mobile;
    /**
     * 用户性别
     * <p>
     * 枚举类 {@link com.forum.module.system.enums.common.SexEnum}
     */
    private Integer sex;
    /**
     * 账号状态
     * <p>
     * 枚举 {@link com.forum.framework.common.enums.CommonStatusEnum}
     */
    private Integer status;
    /**
     * 最后登录ip
     */
    private String loginIp;
    /**
     * 最后登录时间
     */
    private LocalDateTime loginDate;

    public UserDO() {
    }

    public UserDO(Long id, String username, String password, String nickname, String remark, String email, String avatar, String mobile, Integer sex, Integer status, String loginIp, LocalDateTime loginDate) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.nickname = nickname;
        this.remark = remark;
        this.email = email;
        this.mobile = mobile;
        this.sex = sex;
        this.status = status;
        this.loginIp = loginIp;
        this.loginDate = loginDate;
        this.avatar = avatar;
    }

    public Long getId() {
        return id;
    }

    public UserDO setId(Long id) {
        this.id = id;
        return this;
    }

    public String getUsername() {
        return username;
    }

    public UserDO setUsername(String username) {
        this.username = username;
        return this;
    }

    public String getPassword() {
        return password;
    }

    public UserDO setPassword(String password) {
        this.password = password;
        return this;
    }

    public String getNickname() {
        return nickname;
    }

    public UserDO setNickname(String nickname) {
        this.nickname = nickname;
        return this;
    }

    public String getRemark() {
        return remark;
    }

    public UserDO setRemark(String remark) {
        this.remark = remark;
        return this;
    }

    public String getEmail() {
        return email;
    }

    public UserDO setEmail(String email) {
        this.email = email;
        return this;
    }

    public String getMobile() {
        return mobile;
    }

    public UserDO setMobile(String mobile) {
        this.mobile = mobile;
        return this;
    }

    public Integer getSex() {
        return sex;
    }

    public UserDO setSex(Integer sex) {
        this.sex = sex;
        return this;
    }

    public Integer getStatus() {
        return status;
    }

    public UserDO setStatus(Integer status) {
        this.status = status;
        return this;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public UserDO setLoginIp(String loginIp) {
        this.loginIp = loginIp;
        return this;
    }

    public LocalDateTime getLoginDate() {
        return loginDate;
    }

    public UserDO setLoginDate(LocalDateTime loginDate) {
        this.loginDate = loginDate;
        return this;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserDO userDO = (UserDO) o;
        return Objects.equals(id, userDO.id) && Objects.equals(username, userDO.username) && Objects.equals(password, userDO.password) && Objects.equals(nickname, userDO.nickname) && Objects.equals(remark, userDO.remark) && Objects.equals(email, userDO.email) && Objects.equals(mobile, userDO.mobile) && Objects.equals(sex, userDO.sex) && Objects.equals(status, userDO.status) && Objects.equals(loginIp, userDO.loginIp) && Objects.equals(loginDate, userDO.loginDate) && Objects.equals(avatar, userDO.avatar);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, password, nickname, remark, email, mobile, sex, status, loginIp, loginDate, avatar);
    }
}
